package org.dawning.shop.category.controller;

import org.dawning.shop.category.service.ViewCategoryService;
import org.dawning.shop.core.base.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by L on 2017/6/12.
 */
@RestController
@RequestMapping("/PC/category")
public class ViewCategoryController {


    @Autowired
    private ViewCategoryService pcCategoryService;

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public BaseResult add(@RequestParam String name, @RequestParam(required = false) String code, @RequestParam(required = false) String parentId, @RequestParam(required = false) int sort, @RequestParam String baseCategory){
        return pcCategoryService.add(name,code,parentId,sort,baseCategory);
    }

    @RequestMapping(value = "/delete/{id}",method = RequestMethod.POST)
    public BaseResult add(@PathVariable String id){
        return pcCategoryService.delete(id);
    }

    @RequestMapping(value = "/get/{id}",method = RequestMethod.POST)
    public BaseResult get(@PathVariable String id){
        return pcCategoryService.get(id);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public BaseResult add(@RequestParam String id,@RequestParam String name,@RequestParam(required = false) String code,@RequestParam(required = false) String parentId,@RequestParam(required = false) int sort,@RequestParam String baseCategory){
        return pcCategoryService.update(id,name,code,parentId,sort,baseCategory);
    }

}